package com.test.demo.redisson.web;

import org.redisson.api.RAtomicLong;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * @ClassName RedisTestController
 * @Description
 * @Author laigl
 * @Date 2020/4/8 16:26
 **/
@RestController
public class RedisTestController {

    @Autowired
    private RedissonClient redissonClient;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private ReactiveRedisTemplate reactiveRedisTemplate;

    @GetMapping(value = "test")
    public void findInterfaceByPage() {
        RAtomicLong rAtomicLong = redissonClient.getAtomicLong("test");
        rAtomicLong.set(1);
        System.out.println(rAtomicLong.get());

        redisTemplate.opsForValue().set("test", "1111");
        System.out.println(redisTemplate.opsForValue().get("test"));
        Mono mono = reactiveRedisTemplate.opsForValue().get("test");
        mono.subscribe(System.out::println);

    }

}
